package com.deep.stream.service.impl;

import com.example.kafka.service.StreamProducerService;
import com.example.kafka.stream.NcovReportChannel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Service;

@Service
@EnableBinding(NcovReportChannel.class)
public class StreamProducerImpl implements StreamProducerService {

    @Autowired
    NcovReportChannel ncovReportChannel;

    @Override
    public boolean send(String msg) {
        Message<String> message = MessageBuilder.withPayload(msg).build();
        return ncovReportChannel.ncovReportOut().send(message);
    }
}
